// pages/live.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
     
      startX:'',
      msg:[{url:'https://img.alicdn.com/imgextra/i2/2213900457790/O1CN01Cz31sx27PsEgCVGfh_!!2213900457790-0-shopmanager.jpg',t1:'GenioLaMode潮牌',t2:'周一',t3:'请确认收货地址',isActive:false},
      {url:'https://gw.alicdn.com/imgextra//d7/07/TB1KaTdSFXXXXamXVXXSutbFXXX.jpg_110x10000q50.jpg_.webp',t1:'Baleno 班尼路天猫旗舰店',t2:'周日',t3:'恭喜您获得再买一单专属优惠',isActive:false},
      {url:'https://gw.alicdn.com//9d/94/TB1aWysRVXXXXcKXpXXwu0bFXXX.png_110x10000.jpg_.webp',t1:'JeansWest 真维斯天猫旗舰店',t2:'周五',t3:'工作部门:系统维护 请假申请人:xxx',isActive:false},
      {url:'https://img.alicdn.com/imgextra/i2/2048258955/O1CN0135PkUs2G1RZswstZ5_!!2048258955-2-shopmanager.png',t1:'南极人裤袜旗舰店',t2:'昨天',t3:'您有一条店铺消息',isActive:false}]
  },
  //触摸
  touchstart(e){
     this.setData({
      startX: e.touches[0].clientX
     })
  },

  touchend(e){
     const endX=e.changedTouches[0].clientX;
     const startX=this.data.startX;
     const msg=this.data.msg
     const index = e.currentTarget.dataset.index;
      //判断左滑
      if(startX-endX>5){
        msg[index].isActive=true
      }else{
        msg[index].isActive=false
  }
  this.setData({
    msg:msg
  })
},
remove_msg(e){
   const index = e.currentTarget.dataset.index
   const msg=this.data.msg
   msg.splice(index,1)
   this.setData({
     msg:msg
   })
}
})